package com.yuanfengerp.goodsTypeInfo.servicer.impl;

import com.yuanfengerp.goodsTypeInfo.dao.IProductTypeDao;
import com.yuanfengerp.goodsTypeInfo.model.ProductType;
import com.yuanfengerp.goodsTypeInfo.servicer.IProductTypeService;
import com.yuanfengerp.publicUtil.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class IProductTypeServiceImpl implements IProductTypeService {
    @Autowired
    private IProductTypeDao productTypeDao;

    /**
     *  添加商品类型
     * @param productType // 商品类型
     * @return Result //返回添加结果
     */
    @Override
    public Result<Integer> insertProductType(ProductType productType) {
        int i = productTypeDao.insertProductType(productType);
        if (i>0){
            return Result.success();
        }else{
            return Result.failure(400,"添加失败");
        }
    }

    /**
     * 查询商品类型
     * @param condition // 查询条件
     * @return // 返回查询结果
     */
    @Override
    public Result<List<ProductType>> selectProductType(Map<String, Object> condition) {
        List<ProductType> productTypes = productTypeDao.selectProductType(condition);
        if (!productTypes.isEmpty()) {
            return Result.success(productTypes);
        } else {
            return Result.failure(400, "没有相关数据");
        }
    }


    @Override
    public Result<Integer> updateProductType(ProductType productType) {
        return null;
    }

    @Override
    public Result<Integer> updateProductTypeById(ProductType productType) {
        return null;
    }
}
